package com.itcast.song.controller;

import com.itcast.song.pojo.User;
import com.itcast.song.response.Result;
import com.itcast.song.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping
    public Result queryAll(){
        return Result.okResult(userService.queryAll());
    }
    @PostMapping
    public Result addUser(@RequestBody User user){
        return Result.okResult(userService.addUser(user));
    }
    @RequestMapping("/{uuid}")
    public Result deleteUser(@PathVariable("uuid") Integer uuid){
        return Result.okResult(userService.deleteUser(uuid));
    }
    @PutMapping
    public Result updateUser(User user){
        return Result.okResult(userService.updateUser(user));
    }
}
